package com.poizon.infrastructure.starter.redis;

import com.poizon.infrastructure.cache.core.repo.ICacheDbRepo;
import com.poizon.infrastructure.cache.core.util.IRedisUtil;
import lombok.AllArgsConstructor;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @see ICacheDbRepo
 */
@AllArgsConstructor
public class RedisCacheDbRepo implements ICacheDbRepo {
    private IRedisUtil iRedisUtil;

    @Override
    public String get(String key, String hashKey) {
        return iRedisUtil.get(key, hashKey);
    }

    @Override
    public void delete(String cacheKey, String hashKey) {
        iRedisUtil.delete(cacheKey, hashKey);
    }

    @Override
    public void setNull(String key, String hashKey, Long cacheNullTimeout, TimeUnit timeUnit) {
        iRedisUtil.setNull(key, hashKey, cacheNullTimeout, timeUnit);
    }

    @Override
    public <R> void set(String key, String hashKey, List<R> rs, Long cacheTimeout, TimeUnit timeUnit) {
        iRedisUtil.set(key, hashKey, rs, cacheTimeout, timeUnit);
    }
}
